﻿@using Kugar.Core.BaseStruct
@using Kugar.Core.Web
@using Kugar.MVC.DaemonUI.Enums
@using Kugar.MVC.DaemonUI.Helpers
@using WS.FlowAuth.Web.Data.EF

@{
    ViewBag.Title = "用户代码列表";
    Layout = "~/Areas/Admin/Views/Shared/Layout.cshtml";

    var lst = (VM_PagedList<base_UserCode>)ViewBag.List;
    var keyword = Request.GetString("Keyword", "");
    var startDt = (DateTime?)ViewBag.StartDt;
    var endDt = (DateTime?)ViewBag.EndDt;

    this.CurrentMenuKey = "usercode";
}

@section ContentBody
{
    @using (var page=WebUI.CustomPage.DataListPage<base_UserCode>().Render())
    {
        using (page.FilterBlock.Render())
        {
            @WebUI.Form.DateRangePicker().Label("过期时间").LabelWidth(4).Css("col-xs-6").StartFieldName("StartDt").EndFieldName("EndDt").StartValue(startDt).EndValue(endDt).Type(DateTimePickerType.Date).Render()

            @WebUI.Form.TextWithButton().Name("Keyword").Css("col-xs-6").Value(keyword).ButtonTitle("搜索").ButtonStyle(ButtonStyleType.Primary).Value(keyword).Render()
        }

        using (var db=page.DataBlock.AddButton(btn=>btn.Text("新增用户代码").ShowModal("/Admin/UserCode/Detail").StyleType(ButtonStyleType.Primary)).Render())
        {
            using (var tbl=db.Table().Data(lst).Render())
            {
                @tbl.Columns.AddIndex()

                @tbl.Columns.AddText().Title("用户代码").Value(x=>x.UserCode)

                @tbl.Columns.AddText().Title("客户名称").Value(x=>x.CustomerName)

                @tbl.Columns.AddText().Title("过期时间").Value(x=>x.ExpireDt.ToString("yyyy-MM-dd"))

                @tbl.Columns.AddText().Title("创建时间").Value(x=>x.CreateDt.ToString("yyyy-MM-dd"))

                @tbl.Columns.AddText().Title("状态").Value(x=>x.IsDeleted?"已禁用":"正常")

                @(tbl.Columns.AddDropDownList().Title("操作")
                    .AddButton((data,btn)=>btn.Title("详情").ShowModal($"/Admin/UserCode/Detail?UserCodeID={data.UserCodeID}"))
                    .AddCommandItem((data,btn)=>btn.Hide(data.IsDeleted).Title("禁用").Args(new {data.UserCodeID}).CmdName("delete").Tips("是否确定禁用").Url("MethodHandler"))
                    .AddCommandItem((data,btn)=>btn.Hide(!data.IsDeleted).Title("启用").Args(new {data.UserCodeID}).CmdName("reset").Tips("是否确定启用").Url("MethodHandler"))
                    )
            }
        }

    }

}


@section Styles
{
    <style>
        .pagination > .active > a {
            background-color: #c0e2ff;
            border-color: #c0e2ff;
        }
    </style>

}